$("#joinTime").datepicker({
    format: 'yyyy-mm-dd'
});

$CertusJsonAjax.ajax("queryYGRZProcessTrace",{
    "processInstanceId": $CertusJsonAjax.getProInstanceId(),
    "stepInstanceId": $CertusJsonAjax.getStepInstanceId()
},function(res){
    $$scope.processCCBXTrace = res.data;
})

//查询 基本 数据
$CertusJsonAjax.ajax("baseUserByProcessId",{
    "processInstanceId": $CertusJsonAjax.getProInstanceId(),
    "stepInstanceId": $CertusJsonAjax.getStepInstanceId()
},function(res){

    if(res.data){

        $$scope.rzlcStepEntity = res.data;

        $$scope.rzlcStepEntity.baseUser.departmentUser.companyName = $$scope.getBelongCompanyName($$scope.rzlcStepEntity.baseUser.belongCompanyCode);


        $$scope.rzlcStepEntity.processInstanceId = $CertusJsonAjax.getProInstanceId();
        $$scope.rzlcStepEntity.stepInstanceId = $CertusJsonAjax.getStepInstanceId();
        $$scope.companySelect = [
            {name:"赛特斯集团",code:"STSJT"},
            {name:"赛特斯广东",code:"STSGD"},
            {name:"赛特斯南京",code:"STSNJ"},
            {name:"赛特斯北京",code:"STSBJ"},
            {name:"赛特斯上海",code:"STSSH"},
            {name:"融合运维事业部",code:"SYB-RX"},
            {name:"浩方科技",code:"HFKJ"},
            {name:"浩方信息",code:"HFXX"}
        ]

        for(var cs in $$scope.companySelect){
            if($$scope.companySelect[cs].code == $$scope.rzlcStepEntity.baseUser.belongCompanyCode){
                $$scope.rzlcStepEntity.baseUser.departmentUser.companyName = $$scope.companySelect[cs].name;
            }
        }
    }
});

$$scope.seatCity = [
    {name:"南京",code:"NJ"},
    {name:"北京",code:"BJ"},
    {name:"上海",code:"SH"},
    {name:"广东",code:"GD"}
]

$$scope.ridgepoleSelect = [
    {name:"南京18号楼",code:"B18"},
    {name:"南京9号楼",code:"B09"},
    {name:"广东0号楼",code:"B00"},
    {name:"首享科技大厦",code:"B02"},
    {name:"蓟门壹号",code:"B01"},
    {name:"创智天地",code:"B06"}
]



$$scope.selectChange1 = function(){
    if($$scope.seatSelect.cityLocation && $$scope.seatSelect.buildingLocation && $$scope.seatSelect.floorLocation){
        $CertusJsonAjax.ajax("seatSelect",$$scope.seatSelect,function(res){
            $$scope.seatSelectSeat = res.data;

            $$scope.rzlcStepEntity.baseUser.basePlace = $$scope.seatSelect.cityLocation +"-"+ $$scope.seatSelect.buildingLocation +"-"+ $$scope.seatSelect.floorLocation
        })
    }
}

$$scope.selectChange2 = function(aa){
    if(aa == "B18"){
        $$scope.floorLevelSelect = [
            {name:"南京1F",code:"F01"},
            {name:"南京2F",code:"F02"},
            {name:"南京3F",code:"F03"},
            {name:"南京4F",code:"F04"},
        ]
    }else if(aa == "B09"){
        $$scope.floorLevelSelect = [
            {name:"南京1F",code:"F01"},
        ]
    }else if(aa == "B00"){
        $$scope.floorLevelSelect = [
            {name:"广东16F",code:"F16"}
        ]
    }else if(aa == "B01"){
        $$scope.floorLevelSelect = [
            {name:"蓟门壹号8F",code:"F8"}
        ]
    }else if(aa == "B02"){
        $$scope.floorLevelSelect = [
            {name:"首享科技大厦6F",code:"F6"}
        ]
    }else if(aa == "B06"){
        $$scope.floorLevelSelect = [
            {name:"创智天地11F",code:"F11"}
        ]
    }

    if($$scope.seatSelect.cityLocation && $$scope.seatSelect.buildingLocation && $$scope.seatSelect.floorLocation){
        $CertusJsonAjax.ajax("seatSelect",$$scope.seatSelect,function(res){
            $$scope.seatSelectSeat = res.data;
        })
    }
}

$$scope.selectChange3 = function(){
    if($$scope.seatSelect.cityLocation && $$scope.seatSelect.buildingLocation && $$scope.seatSelect.floorLocation){
        $CertusJsonAjax.ajax("seatSelect",$$scope.seatSelect,function(res){
            $$scope.seatSelectSeat = res.data;
        })
    }
}

$$scope.getSex = function(a){
    if(a == 1){
        return "男";
    }else{
        return "女";
    }
}

$$scope.getBelongCompanyName = function(companyCode){
    if(companyCode == "STSJT"){
        return "赛特斯集团";
    }else if(companyCode == "STSGD"){
        return "赛特斯广东";
    }else if(companyCode == "HFKJ"){
        return "浩方科技";
    }else if(companyCode == "HFXX"){
        return "浩方信息";
    }else if(companyCode == "STSBJ"){
        return "赛特斯北京";
    }else if(companyCode == "STSNJ"){
        return "赛特斯南京";
    }else if(companyCode == "STSSH"){
        return "赛特斯上海";
    }
}

$$scope.getMarriage = function(a){
    if(a == 1){
        return "已婚";
    }else if(a == 0 ){
        return "未婚";
    }else if(a == 2){
        return "已婚已育";
    }

    return "未婚";
}

$$scope.belongCompanyCodeSelect = [
    {name:"赛特斯广东",code:"STSGD"},
    {name:"赛特斯南京",code:"STSNJ"},
    {name:"赛特斯北京",code:"STSBJ"},
    {name:"赛特斯上海",code:"STSSH"},
    {name:"融合运维事业部",code:"SYB-RX"},
    {name:"浩方科技",code:"HFKJ"},
    {name:"浩方信息",code:"HFXX"}
]


$$scope.seatSubmit = function(){
    if(certusValidateNotnull()){
        $CertusJsonAjax.ajax("seatSubmit",$$scope.rzlcStepEntity,function(res){
            if(res.data == "success"){
                findBacklogPerson($CertusFormAjax,$CertusJsonAjax.getStepInstanceId());
                history.back();
                return;
            }
            layer.msg("數據錯誤");
        })
    }
}


